﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.生产计划.编排生产批.service;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.项目成果管理;
using DXApplicationTangche.UC.订单一览新.订单预览新;

namespace DXApplicationTangche.UC.生产计划.编排生产批
{
    public partial class Form编排生产批 : DevExpress.XtraEditors.XtraForm
    {
        private List<DTO生产批> DTO生产批s = new List<DTO生产批>();
        public Form编排生产批()
        {
        }
        public Form编排生产批(List<DTO生产批> DTO生产批s)
        {
            InitializeComponent();
            this.DTO生产批s = DTO生产批s;
            this.gridControl生产批.DataSource = this.DTO生产批s;
        }
        
        #region 右键功能
        private void 拆批ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form拆批 form = new Form拆批(
                FunctionHelper.GetgridViewValue(
                    this.gridView生产批,
                    this.gridView生产批.FocusedRowHandle,
                    "batchNo"),
                FunctionHelper.GetgridViewValue(
                    this.gridView生产批,
                    this.gridView生产批.FocusedRowHandle,
                    "batchQuantiry"
                        )
                );
            form.ShowDialog();
            if (form.List拆批.Count > 0)
            {
                this.DTO生产批s.Remove(this.DTO生产批s[this.gridView生产批.FocusedRowHandle]);
                this.DTO生产批s.AddRange(form.List拆批);
            }
            this.gridControl生产批.DataSource = this.DTO生产批s;
            this.gridView生产批.RefreshData();
        }
        private void 加急ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.DTO生产批s[this.gridView生产批.FocusedRowHandle]
                    = 编排生产批Service.post变更为加急状态(
                        FunctionHelper.GetgridViewValue(
                            this.gridView生产批,
                            this.gridView生产批.FocusedRowHandle,
                            "batchNo"
                            )
                        );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.gridView生产批.RefreshData();
        }

        private void 不加急ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.DTO生产批s[this.gridView生产批.FocusedRowHandle]
                    = 编排生产批Service.post变更为不加急状态(
                        FunctionHelper.GetgridViewValue(
                            this.gridView生产批,
                            this.gridView生产批.FocusedRowHandle,
                            "batchNo"
                            )
                        );
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.gridView生产批.RefreshData();
        }
        #endregion
    }
}